package com.csx.base.design.behavior.command;

import java.util.Collections;

/**
 * @author cuisongxu
 * @date 2022/10/12 12:12
 */
public class Client {

    public static void main(String[] args) {
        Keyboard keyboard = new Keyboard();
        TV tv = new TV();

        TVOnCommand tvOnCommand = new TVOnCommand(tv);
        TVOffCommand tvOffCommand = new TVOffCommand(tv);
        TVChannelUpCommand tvChannelUpCommand = new TVChannelUpCommand(tv);

        // 按键与命令映射
        keyboard.bindKeyCommand(
                Keyboard.KeyCode.F1,
                Collections.singletonList(tvOnCommand)
        );

        keyboard.bindKeyCommand(
                Keyboard.KeyCode.LEFT,
                Collections.singletonList(tvChannelUpCommand)
        );

        keyboard.bindKeyCommand(
                Keyboard.KeyCode.ESC,
                Collections.singletonList(tvOffCommand)
        );


        // 触发按键
        keyboard.onKeyPressed(Keyboard.KeyCode.F1);
        keyboard.onKeyPressed(Keyboard.KeyCode.LEFT);
        keyboard.onKeyPressed(Keyboard.KeyCode.UP);
        keyboard.onKeyPressed(Keyboard.KeyCode.ESC);


    }
}
